package com.linghang.back.exception;

import lombok.Getter;

/**
 * 系统错误码枚举
 */
@Getter
public enum ErrorCode {
    
    // 通用错误码 1000-1999
    SYSTEM_ERROR(1000, "系统错误"),
    PARAM_ERROR(1001, "参数错误"),
    
    // 用户相关错误码 2000-2999
    USER_MOBILE_EXISTS(2001, "手机号已注册"),
    USER_USERNAME_EXISTS(2002, "用户名已存在"),
    VERIFY_CODE_ERROR(2003, "验证码不正确或已过期"),
    USER_NOT_FOUND(2004, "用户不存在"),
    INVITER_ALREADY_BOUND(2005, "已经绑定邀请关系，不能重复绑定"),
    INVITE_CODE_INVALID(2006, "邀请码无效"),
    CANNOT_INVITE_SELF(2007, "不能使用自己的邀请码"),
    
    // 权限相关错误码 3000-3999
    UNAUTHORIZED(3001, "未授权访问"),
    TOKEN_EXPIRED(3002, "令牌已过期"),
    TOKEN_INVALID(3003, "无效的令牌"),
    
    // 团队相关错误码 4000-4999
    TEAM_NOT_FOUND(4001, "团队不存在"),
    TEAM_NAME_EXISTS(4002, "团队名称已存在"),
    NOT_TEAM_MEMBER(4003, "不是团队成员"),
    NOT_TEAM_ADMIN(4004, "不是团队管理员"),
    
    // 佣金相关错误码 5000-5999
    COMMISSION_ERROR(5001, "佣金计算错误"),
    INSUFFICIENT_BALANCE(5002, "余额不足");
    
    private final int code;
    private final String message;
    
    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public BusinessException exception() {
        return new BusinessException(this.code, this.message);
    }
    
    public BusinessException exception(String message) {
        return new BusinessException(this.code, message);
    }
} 